define(['vue'],
  function (
    Vue
  ) {
    function render() {
      new Vue({
        el: '#{{name}}',
        data() {
          return {
            gridOptions: {
              pagerConfig: {
                pageSize: 10
              },
              sortConfig: {
                remote: true
              },
              proxyConfig: {
                sort: true,
                ajax: {
                  query: async ({page,sort}) => {
                    const params = {
                      pageIndex: page.currentPage,
                      pageSize: page.pageSize,
                      orderBy: sort.field,
                      sortBy: sort.order
                    }
                    Object.assign(params,this.form)
                    return $.elApi(params)
                  }
                }
              }
            },
            form: {
            },
            columns: [
              {
                field: '',
                title: '',
                formatter: ['dictFilter', 'projectChange_type']
              },
              {
                title: '操作',
                width: 50,
                slots: {
                  default: 'operate'
                }
              }
            ]
          }
        },
        created() {

        },
        methods: {
          async deleteRow(row){
            await this.$confirm('是否确认删除?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            })
            await $.elApi.projectChangeRecord.deleteById({id:row.id})
            this.$message.success('删除成功')
            this.search()
          },
          search() {
            this.$refs.vxegrid.commitProxy('reload')
          },
          add(id){
            window.CACHE_.id = id
            $.form.sidepage(ELMP.resource('form.html', '{{name}}'), null, null, null, ()=> {
              this.search()
            });
          },
          cellClick({row,column}){
            if(column.field!== 'projChangeNo') return
            this.add(row.id)
          }
        }
      })
    }
    return {
      init: render
    }
  })